#include "DebugInfoNode.h"
#include "cinder/params/Params.h"
#include "cinder/app/AppBasic.h"
#include <sstream>
#include "Timer.h"



using namespace Boon;
using namespace Rendering;
using namespace ci;
using namespace ci::app;


DebugInfoNode::DebugInfoNode(void)
	: SceneNode( GameObject::INVALID_ID, "Debug_Draw", PASS_NOT_RENDERED )
{
	m_Font = gl::TextureFont::create( ci::Font( "Times New Roman", 24 ) );
}


DebugInfoNode::~DebugInfoNode(void)
{
}

bool DebugInfoNode::IsVisible( Scene* scene ) const
{
	return true;
}

bool DebugInfoNode::PreRender( Scene* scene )
{
	gl::pushMatrices();
	return true;	
}

bool DebugInfoNode::Render( Scene* scene )
{
	gl::pushMatrices();
	gl::scale( .1f, -.1f, .1f );
	std::ostringstream oss;
	oss << "FPS Logic: " << Boon::Timer::GetInstance().FPSLogic() << " ";
	gl::drawString( oss.str(), Vec2f( 800, -1000 ), cinder::Color::white(), m_Font->getFont() );
	oss.str( "" );

	oss << "FPS Rendering: " << Boon::Timer::GetInstance().FPSRendering() << " ";
	std::string render( oss.str() );
	gl::drawString( oss.str(), Vec2f( 800, -980 ), cinder::Color::white(), m_Font->getFont() );
	gl::popMatrices();
	return true;
}

bool DebugInfoNode::PostRender( Scene* scene )
{
	ci::gl::popMatrices();
	return true;	
}
